﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace DateTimeSortHomeWork
{
    class Program
    {
        public static int DayOfWeekToInt(DateTime dt)
        {
            int i =0;
            switch (dt.DayOfWeek)
            {
                case DayOfWeek.Friday:
                    return i = 5;
                    break;
                case DayOfWeek.Monday:
                    return i = 1;
                    break;
                case DayOfWeek.Saturday:
                    return i = 6;
                    break;
                case DayOfWeek.Sunday:
                    return i = 7;
                    break;
                case DayOfWeek.Thursday:
                    return i = 4;
                    break;
                case DayOfWeek.Tuesday:
                    return i = 2;
                    break;
                case DayOfWeek.Wednesday:
                    return i = 3;
                    break;
                default:
                    return i;
                    break;
            }
            
        }
        public static int DOWSort(DateTime a, DateTime b)
        {
            int i = 0;
            if (DayOfWeekToInt(a) > DayOfWeekToInt(b))
            {
                i = 1;
            }
            else if (DayOfWeekToInt(a) < DayOfWeekToInt(b))
            {
                i = -1;
            }
            else i = 0;
            return i;
        }
        static void Main(string[] args)
        {
            List<DateTime> dates = new List<DateTime>();
            using (StreamReader stringDate = new StreamReader("Dates.txt"))
            {
                string line;
                while ((line = stringDate.ReadLine()) != null)
                {
                    dates.Add(DateTime.Parse(line));
                }
            }
            Console.WriteLine("Unsorted dates");
            foreach(DateTime dt in dates)
            {
                Console.Write(dt.DayOfWeek+" ");
                Console.WriteLine(dt);
            }
            dates.Sort(DOWSort);
            Console.WriteLine();
            Console.WriteLine("Sorted dates");
            foreach (DateTime dt in dates)
            {
                Console.Write(new System.Globalization.CultureInfo("ru-Ru").DateTimeFormat.GetDayName(dt.DayOfWeek) + " ");
                Console.WriteLine(dt.ToString("F", new System.Globalization.CultureInfo("ru-Ru")));
            }
            Console.ReadLine();
        }
    }
}
